package com.hss01248.dialog.adapter;

import ohos.agp.components.LayoutScatter;
import ohos.app.Context;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;

/**
 * Created by Administrator on 2017/12/9.
 */

public abstract class SuperPagerHolder<T> implements Component.BindStateChangedListener,ILifeCycle{

    public ComponentContainer rootView;

    public SuperPagerHolder(Context context){
        int layoutRes = setLayoutRes();
        if(layoutRes !=0){
            LayoutScatter scatter = LayoutScatter.getInstance(context);
            rootView = (ComponentContainer)scatter.parse(layoutRes, null, false);
        }else {
            rootView = setRootView(context);
        }
        rootView.setBindStateChangedListener(this);
        findViews();
    }

    protected ComponentContainer setRootView(Context context) {
        return null;
    }

    protected abstract int setLayoutRes();

    protected abstract void findViews();

    public  abstract void assingDatasAndEvents(Context context, T bean,int position); // @Nullable

    @Override
    public void onComponentBoundToWindow(Component v) {

    }

    @Override
    public void onComponentUnboundFromWindow(Component v) {

    }

    @Override
    public void onDestory() {

    }
}
